package com.neonbacon.snake;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

public class InGame extends View {
	public InGame(Context context, AttributeSet attrs) {
		super(context, attrs);head = Bitmap.createScaledBitmap(
				BitmapFactory.decodeResource(getResources(),
						R.drawable.snakehead),
				BitmapFactory.decodeResource(getResources(),
						R.drawable.snakehead).getWidth() / 2,
				BitmapFactory.decodeResource(getResources(),
						R.drawable.snakehead).getHeight() / 2, true);
		body = Bitmap.createScaledBitmap(
				BitmapFactory.decodeResource(getResources(),
						R.drawable.snakebody),
				BitmapFactory.decodeResource(getResources(),
						R.drawable.snakebody).getWidth() / 2, 
				BitmapFactory.decodeResource(getResources(),
						R.drawable.snakebody).getHeight() / 2, true);
		
	}
	Level l;
	static Bitmap head;
	static Bitmap body;
	
	@Override
	public boolean onTouchEvent(MotionEvent e){
		super.onTouchEvent(e);
		return true;
	}
	@Override
	protected void onDraw(Canvas c) {
		super.onDraw(c);
		if (l == null)
			l = new Level(this.getContext(), this.getWidth(), this.getHeight(),
					head.getWidth());

		l.draw(c);

		invalidate();
	}
}
